<?
include_once 'include/include.php';
c_create::createClass('news');
$news = new news();
$outvar[headline] = '添加新闻';

if ($_POST){
	$_SESSION[backtype] = $_POST[backtype];
	unset($_POST[backtype]);
	if ($news->submitRecord($_POST)){
		$_SESSION[showtips]	 = $news->action.'成功！';
		if (empty($_POST[Articleid])){
			if ($_SESSION[backtype]==1){	////如果设置为列表页面，成功添加后，跳转到列表页面，或者停留当前页面
				header('location:News_manage.php');
				exit;
			}
		}else {
			$outvar[headline] = '修改新闻';
			////如果修改成功，就重新读取这条记录，如果这里直接用$_post的值的话，如果附件是第一次提交的话
			////将无法显示
			$_POST = $news->getOneRecord($_POST[Articleid],0);
		}
	}else {
		assignMore($news->error);
		$_SESSION[showtips]	 = $news->action.'失败！';
	}
}elseif ($_GET[id]){
	$outvar[headline] = '修改新闻';
	$_POST = $news->getOneRecord($_GET[id],0);
}
if ($_POST){ $_POST = specialhtml(stripslashes_deep($_POST),'Acontent');}
if ($_SESSION[backtype]){
	$_POST[backtype] = $_SESSION[backtype];
}else {
	$_POST[backtype] = 0;
}
$outvar[radios] = array(0=>'当前页',1=>'列表页');
/**
 * 在线编辑系统
 * @param string inputName 
 * @param string inputValue ?
 * @param string height 
 * @param string toolbarSet 
 */
include_once SITE_ROOT."lib/fckeditor/fckeditor.php";
function createEditor($inputName, $inputValue = '',$height='320',$width='100%',$toolbarSet='Default'){
	$editor = new FCKeditor($inputName) ;
	$editor->ToolbarSet = $toolbarSet;
	$editor->BasePath = "../lib/fckeditor/";
	$editor->Width = $width;
	$editor->Height = $height;
	$editor->Value = $inputValue;
	$GLOBALS['t']->assign("editor", $editor->CreateHtml());
}
//$_POST[ztitle] = stripslashes($_POST[ztitle]);
//$_POST[zcontent] = stripslashes($_POST[zcontent]);
createEditor('Acontent',$_POST[Acontent],'320','100%','New');

assignMore($_POST);
$outvar[catalog] = $news->getTypeList();
outFile("news_add");
?>